wayland: Fix GtkMenuButton popups in a terrible, hacky way
authorJasper St. Pierre <jstpierre@mecheye.net>
Thu, 15 May 2014 21:20:00 +0000 (17:20 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Thu, 15 May 2014 22:02:45 +0000 (18:02 -0400)
commit75ecdf50a3d1de29a982df6cd614c2f652504678
treefca1434a904f7aae9b7e3c59a028ee1801dba361
parentf6b3f0bfc791e117b60b2c8407ea38ff4d887407
wayland: Fix GtkMenuButton popups in a terrible, hacky way

Since you can't take grabs on unmapped windows, GtkMenu takes a grab on
the menu in a convoluted way: it first grabs another window, shows the
menu window, and then transfers the grab over to the GtkMenu widget.

For normal menubars, this is perfectly fine, as the first window it grabs
is our toplevel, and that gets picked up in our transient path.  For
GtkMenuButton or other spurious uses of gtk_menu_popup, it creates a new
temporary input-only window which it takes the grab on, known as the "grab
transfer window". Since this window isn't a transient-for of our new menu
widget window, the grab isn't noticed when we go to show it, and thus the
menu ends up as a new toplevel.

Add a special hack to GtkMenu and the Wayland backend which lets us notice
this "grab transfer window", and include it in our grab finding path.

It's sort of terrible to have to hack up the widgets instead of just the
backend, but the alternative would be an entirely new window type which is
managed correctly by GDK. I don't want to write that.
gdk/wayland/gdkwindow-wayland.c
gtk/gtkmenu.c